package com.street.controller.admin;

import ch.qos.logback.core.net.SyslogOutputStream;
import com.qcloud.TXCloudUpload;
import com.street.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.Cleanup;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;

@RestController
@RequestMapping("/admin/common")
@Slf4j
@Api(tags = "通用接口")
public class CommonController {
    @Autowired
    TXCloudUpload txCloudUpload;

    @ApiOperation("文件上传")
    @PostMapping("/upload")
    public Result Upload(@RequestBody MultipartFile file) throws IOException {
        String url = txCloudUpload.Upload(file);
        log.info("上传文件{}",url);
        return Result.success(url);
    }


}
